package com.vint.mi;


/**
 * 1. hard
 * 2. 最小连续元素个数，一个数组和给定值，求最小连续元素个数之和大于或等于给点值
 */
public class Mi75 {
    private static String solution(String line){
        String[] src = line.split(",");
        if(src.length<=1)return String.valueOf(1);
        int[] a = new int[src.length];
        int[] sugar = new int[src.length];
        for(int i=0;i<src.length;i++){
            a[i] = Integer.parseInt(src[i]);
            sugar[i] = 1;
        }
        for(int i=1;i<src.length;i++){
            if(a[i]>a[i-1])sugar[i]=sugar[i-1]+1;
        }
        for(int i=src.length-2;i>=0;i--){
            if(a[i]>a[i+1]&&sugar[i]<=sugar[i+1])sugar[i]=sugar[i+1]+1;
        }
        int sum = 0;
        for(int i=0;i<src.length;i++){
            sum += sugar[i];
        }
        return String.valueOf(sum);
    }

    public static void main(String[] args) {
        System.out.println(solution("19,9,35,74,22"));
    }
}
